package com.inspur.cloud.service.dataspace;

import com.inspur.cloud.dao.dataspace.YarnResourceDao;
import com.inspur.cloud.entity.dataspace.YarnResourceEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class YarnResourceService {
    @Autowired
    private YarnResourceDao yarnResourceDao;

    public void save(YarnResourceEntity yarnResourceEntity){
        yarnResourceDao.save(yarnResourceEntity);
    }
    public void saveAndFlush(YarnResourceEntity yarnResourceEntity){
        yarnResourceDao.saveAndFlush(yarnResourceEntity);
    }
    public void delete(YarnResourceEntity yarnResourceEntity){
        yarnResourceDao.delete(yarnResourceEntity);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public void deleteById(Integer id){
        yarnResourceDao.deleteById(id);
    }
    public YarnResourceEntity findYarnResourceEntityById(Integer id){
        return yarnResourceDao.findYarnResourceEntityById(id);
    }
    public YarnResourceEntity findFirstByQueueName(String queueName){
        return yarnResourceDao.findFirstByQueueName(queueName);
    }
    public YarnResourceEntity findFirstByOwner(Integer owner){
        return yarnResourceDao.findFirstByOwner(owner);
    }
    public YarnResourceEntity findQueueByOwner(Integer owner){
        return yarnResourceDao.findQueueByOwner(owner);
    }
    public List<YarnResourceEntity> findByParentId(Integer parentId){
        return yarnResourceDao.findByParentId(parentId);
    }

    public List<YarnResourceEntity> findAll() {
        return yarnResourceDao.findAll();
    }
    public List<YarnResourceEntity> findByParentIdExceptSelf(Integer parentId,Integer id){
        return yarnResourceDao.findByParentIdExceptSelf(parentId,id);
    }
    public YarnResourceEntity findFirstByQueueNameAndParentId(String queueName, Integer parentId){
        return yarnResourceDao.findFirstByQueueNameAndParentId(queueName,parentId);
    }
    public List<String> findQueueNameByParentId(Integer parentId){
        return yarnResourceDao.findQueueNameByParentId(parentId);
    }
    @Transactional(transactionManager = "transactionManagerDataspace")
    public Integer deleteByParentId(Integer parentId){
        return yarnResourceDao.deleteByParentId(parentId);
    }
    public List<Integer> findIdByParentId(Integer parentId){
        return yarnResourceDao.findIdByParentId(parentId);
    }
}
